#pragma once

#include <qdebug.h>
#include <vector>
#include <QTimer>
#include <HeadPanInstruction.h>
#include <HeadRollInstruction.h>
#include <HeadTiltInstruction.h>
#include <AiboState.h>

class HeadInstructionHandler
{
public:
	HeadInstructionHandler(AiboState* aiboState);
	~HeadInstructionHandler(void);

	bool isRollOn() { return m_RollOn; }
	bool isPanOn() { return m_PanOn; }
	bool isTiltOn() { return m_TiltOn; }

	bool addInstruction( HeadInstruction wInstruction );
	void resetAiboState();
	void sendGeneralInstruction( HeadInstruction* instruction );
	bool sendInstruction( HeadRollInstruction* rollInstruction );
	bool sendInstruction( HeadPanInstruction* panInstruction );
	bool sendInstruction( HeadTiltInstruction* tiltInstruction );

public slots:
	void updateAiboState();
private:
	AiboState* getAiboState() { return m_aiboState; }
	void setAiboState( AiboState *aiboState ) { m_aiboState = aiboState; }
	QVector<HeadInstruction>* getInstructionList() { return m_HeadInstructionList; };

	void turnRollOn() { m_RollOn = true; }
	void turnPanOn() { m_PanOn = true; }
	void turnTiltOn() { m_TiltOn = true; }

	void turnRollOff() { m_RollOn = false; }
	void turnPanOff() { m_PanOn = false; }
	void turnTiltOff() { m_TiltOn = false; }

	QTimer *aiboStateTimer;
	AiboState* m_aiboState;
	QVector<HeadInstruction>* m_HeadInstructionList;
	bool m_RollOn;
	bool m_PanOn;
	bool m_TiltOn;

};
